package org.example.traffic.student;

import org.example.traffic.student.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StudentRepository extends JpaRepository<Student, Integer> {

    // 按照姓名模糊查询学生
    List<Student> findByNameContaining(String name);

    // 按照组织ID查询该组织下的所有学生
    List<Student> findByOrganizationId(Integer organizationId);

    @Query("select s from Student s where s.phone = :phone")
    Student findByPhone(String phone);
}
